package com.jf.yytgd.validation.validator;

import com.jf.yytgd.validation.constrain.VisibleASCII;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * Created with IntelliJ IDEA
 * Description: VisibleASCII验证逻辑实现
 * User:22954
 * Date:2025-01-14
 * Time:10:43
 */
public class VisibleASCIIValidator implements ConstraintValidator<VisibleASCII, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
            return false;
        }
        for (char c : value.toCharArray()) {
            if (c <= 32 || c > 127) {
                return false;
            }
        }
        return true;
    }
}
